﻿

using OpenCvSharp;

using System;

using Xc.DataAccess.CodeReader.Properties;
using Xc.DataAccess.Core;

namespace Xc.DataAccess.CodeReader.Models.Filters
{
    /// <summary>
    /// 绘制遮罩
    /// </summary>
    [Filter("绘制遮罩",FilterType.Draw)]
    public class DrawMarkerFilter : FilterBase
    {
        /// <summary>
        /// 位置
        /// </summary>
        [InputParameter("位置")]
        public CVPoint Position { get; set; } = new CVPoint();
        /// <summary>
        /// 颜色
        /// </summary>
        [InputParameter("颜色")] 
        public Scalar Color { get; set; }
        /// <summary>
        /// 遮罩类型
        /// </summary>
        [InputParameter("遮罩类型")]
        public MarkerTypes MarkerType { get; set; }
        /// <summary>
        /// 遮罩大小
        /// </summary>
        [InputParameter("遮罩大小")]
        public int MarkSize { get; set; } = 20;
        /// <summary>
        /// 粗细
        /// </summary>
        [InputParameter("粗细")]
        public int Thickness { get; set; } = 1;
        /// <summary>
        /// 线条类型
        /// </summary>
        [InputParameter("线条类型")]
        public LineTypes LineType { get; set; } = LineTypes.Link8;

        internal override ResultData<Mat> UseChannel(Mat mat, FilterBase[] filterInfos, FilterBase preFilterBase)
        {
            Cv2.DrawMarker(mat,Position,Color,MarkerType,MarkSize,Thickness,LineType);
            return ResultData<Mat>.Accept(TextResource.filter_action_complete, mat);
        }
    }
}
